﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TwitterApp.BusinessLogic;
using Twitterizer.Framework;

namespace TwitterApp
{
    namespace TwitterInterface
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            private Twitter twitter;

            public MainWindow()
            {
                InitializeComponent();
            }

            private void Window_Loaded(object sender, RoutedEventArgs e)
            {

            }

            private void btnLogin_Click(object sender, RoutedEventArgs e)
            {
                this.grdLogin.Visibility = Visibility.Hidden;
                this.tabWindow.Visibility = Visibility.Visible;
                LoadMainFeed();
            }

            private void LoadMainFeed()
            {
                twitter = new Twitter(this.txtUsername.Text, this.txtPassword.Password);
                StatusCollection friendstimeline = new StatusCollection(twitter);
                friendstimeline.LoadFriendsTimeLine();
                foreach (Status status in friendstimeline)
                {
                    Tweet tweet = new Tweet();
                    tweet.LoadTweet(status);
                    this.stkStatusList.Children.Add(tweet);
                }
            }

            private void tabWindow_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                switch (tabWindow.SelectedIndex)
                {
                    case(0):
                    {
                        this.Title = "Twitter App - Feed";
                        break;
                    }
                    case(1):
                    {
                        this.Title = "Twitter App - Replies";
                        break;
                    }
                }
            }
        }
    }
}
